const mongoose = require("mongoose");

const url = "mongodb://127.0.0.1:27017/h51803"

mongoose.connect(url, { useNewUrlParser: true })

const db = mongoose.connection; //理解为数据库database缩写

db.on("open", () => {
    console.log("数据库已连接")
})

db.on('error', console.error.bind(console, '链接错误'));

module.exports = {
    mongoose,
    db
}